<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	    		xmlns:ui="http://java.sun.com/jsf/facelets"
	  			xmlns:h="http://java.sun.com/jsf/html"
	  			xmlns:f="http://java.sun.com/jsf/core"
	  			xmlns:s="http://jboss.com/products/seam/taglib"
				xmlns:a4j="http://richfaces.org/a4j"
				xmlns:a="http://richfaces.org/a4j"
				xmlns:rich="http://richfaces.org/rich">
	
			<a:form>
				<a:commandButton id="showAvailableVouchers" value="Show available vouchers" action="#{availableVouchersManage.show}" 
					reRender="searchResults2"/>
				&#160;
				<a:status>
					<f:facet name="start">
						<h:graphicImage value="/img/spinner.gif"/>
					</f:facet>
				</a:status>
			</a:form>
			<rich:spacer height="30" />
			<a:form>
				<a:outputPanel id="searchResults2">
					<rich:spacer height="30" rendered="#{availableVouchers != null and availableVouchers.rowCount==0}"/>
					<h:outputText value="No voucher requests" class="entry errors" 
						rendered="#{availableVouchers != null and availableVouchers.rowCount==0}"/>							
					<rich:spacer height="30" />					
					<rich:datascroller align="left"  for="avlist" maxPages="20" rendered="#{availableVouchers.rowCount>0}" />
					<rich:spacer height="30" />
					<rich:dataTable width="483" id="avlist" rows="10" columnClasses="col"
						value="#{availableVouchers}" var="av" rendered="#{availableVouchers.rowCount>0}">
						<f:facet name="header">
							<rich:columnGroup>
								<h:column>
									<h:outputText styleClass="headerText" value="Id" />
								</h:column>								
								<h:column>
									<h:outputText styleClass="headerText" value="Value" />
								</h:column>
								<h:column>
									<h:outputText styleClass="headerText" value="Hash" />
								</h:column>
								<h:column>
									<h:outputText styleClass="headerText" value="Decline" />
								</h:column>								
							</rich:columnGroup>
						</f:facet>

						<h:column>
							<h:outputText value="#{av.id}" />
						</h:column>
						<h:column>
							<h:outputText value="#{av.value}" />
						</h:column>
						<h:column>
							<h:outputText value="#{av.voucherHash}" />
						</h:column>
						<h:column>
							<span class="nothing">
								<a:commandLink action="#{availableVouchersManage.decline(av)}" 
									linkStyle="button" reRender="searchResults2" rendered="#{av.active==true}">
										<h:graphicImage value="/img/nope.png"/>
								</a:commandLink>
								<h:graphicImage value="/img/nope_grey.png" rendered="#{av.active==false}"/>
							</span>
						</h:column>													
					</rich:dataTable>					
				</a:outputPanel>
			</a:form>
			<div class="entry errors">
				<rich:messages globalOnly="true"/>
			</div>	
</ui:composition>